package com.mindskip.xzs.service.impl;

import com.mindskip.xzs.repository.base.MyMapper;
import com.mindskip.xzs.service.BaseService;

public abstract class BaseServiceImpl<T> implements BaseService<T> {

    private final MyMapper<T> myMapper;

    public BaseServiceImpl(MyMapper<T> myMapper) {
        this.myMapper = myMapper;
    }

    @Override
    public int deleteById(Integer id) {
        return myMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(T record) {
        return myMapper.insert(record);
    }

    @Override
    public int insertByFilter(T record) {
        return myMapper.insertSelective(record);
    }

    @Override
    public T selectById(Integer id) {
        return myMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByIdFilter(T record) {
        return myMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateById(T record) {
        return myMapper.updateByPrimaryKey(record);
    }
}
